import Vue from 'vue'
import Vuex from 'vuex'
import ErrorCode from "./modules/ErrorCode";
import VisualInspectionReport from "./modules/SEM4000/VisualInspectionReport";
import CustomerWaiveForm from "./modules/SEM4000/CustomerWaiveForm";
import ShippingSheet from "./modules/SEM4000/ShippingSheet";
import PackageHistoryReport from "./modules/SEM4000/PackageHistoryReport";
import js1000 from "./modules/SEM1000/js1000";
import js3100 from "./modules/SEM3000/SEM3100/js3100";
import js3200 from "./modules/SEM3000/SEM3200/js3200";
import js3300 from "./modules/SEM3000/SEM3300/js3300";
import js3400 from "./modules/SEM3000/SEM3400/js3400";
import js3500 from "./modules/SEM3000/SEM3500/js3500";
import barTender from "./modules/BarTender/BarTenderTemplateConfig";
import JsNormalLots from "./modules/NormalLots/JsNormalLots";
import ProductConfig from "@/store/modules/ProductConfig/ProductConfig";
import reprint from "@/store/modules/Reprint/Reprint";
import JsRunLot from "./modules/RunLots/JsRunLot";
import JsCodeScanner from "./modules/CodeScanner/JsCodeScanner";

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        device: "desktop",
        navigationTheme: "dark",//导航主题
        menuKeys: window.localStorage.getItem('menuKeys') ? JSON.parse(window.localStorage.getItem('menuKeys')) : [],//选中页面的key
        openKeys: window.localStorage.getItem('openKeys') ? JSON.parse(window.localStorage.getItem('openKeys')) : [],//展开的菜单key
        currentLocale: window.localStorage.getItem('locale') ? window.localStorage.getItem('locale') : 'en',
        firstLoginFlag: false,
        userButtons: [],
    },
    mutations: {
        setUserButtons(state, val) {
            state.userButtons = val
        },
        TOGGLE_DEVICE: (state, device) => {
            state.device = device;
        },
        navigationThemeChange: (state, payload) => {
            state.navigationTheme = payload.theme;
        },
        setMenuKeys(state, key) {
            state.menuKeys = key;
        },
        setInitLoginFlag(state, val) {
            state.firstLoginFlag = val
        },
        setLoginData(state, data) {
            window.localStorage.setItem("userIdMes", data.data.loginId);
            window.localStorage.setItem("token", data.data.tokenValue);
            window.localStorage.setItem("tokenName", data.data.tokenName);
        },
    },
    actions: {},
    modules: {
        // js2000: js2000,
        js3100: js3100,
        js3200: js3200,
        js3300: js3300,
        js3400: js3400,
        js3500: js3500,
        js1000: js1000,
        reprint: reprint,
        VisualInspectionReport: VisualInspectionReport,
        CustomerWaiveForm: CustomerWaiveForm,
        ShippingSheet: ShippingSheet,
        barTender: barTender,
        JsNormalLots: JsNormalLots,
        JsRunLot: JsRunLot,
        JsCodeScanner: JsCodeScanner,
        ErrorCode: ErrorCode,
        ProductConfig: ProductConfig,
        PackageHistoryReport: PackageHistoryReport,
    }
})
